Full source code website bán hàng thương mại điện tử gần giống shopee
473.330 lượt xem;
1 <?
2
3 function chuanhoa($s)
4
5 {
6
7 //return trim(htmlspecialchars($s));
8
9 return str_replace("<","<",trim($s));
10
11 }
12
13
14
15 function breakline($s)
16
17 {
18
19 return str_replace("\n","<br>",$s);
20
21 }
22
23
24
25 function GetFileExtention($filename)
26
27 {
28
29 return strrchr($filename, ".");
30
31 }
32
33
34
35 function CheckUpload($f,$ext="",$maxsize=0,$req=0)
36
37 {
38
39 $fname=strtolower(basename($f['name']));
40
41 $ftemp=$f["tmp_name"];
42
43 $fsize=$f["size"];
44
45 $fext=GetFileExtention($fname);
46
47 if($fsize==0)
48
49 {
50
51 if ($req!=0) return "Bạn chưa chọn file";
52
53 return "";
54
55 }
56
57 else
58
59 {
60
61 if ($ext!="") if (strpos($ext, $fext)===false) return "Tập tin không đúng định dạng : $fname";
62
63 //if(($f["type"] != "image/gif" ) && ($f["type"] != "image/pjpeg")) return "Định dạng file không hợp lệ";
64
65 if ($maxsize>0) if ($fsize > $maxsize) return "Kích thước hình phải nhỏ hơn ".$maxsize." byte";
66
67 }
68
69 return "";
70
71 }
72
73
74
75 function MakeUpload($f,$newfile)
76
77 {
78 //if (file_exists($newfile)) return false;
79
80 if (move_uploaded_file($f["tmp_name"], $newfile)) return $newfile;
81
82 return false;
83
84 }
85
86 function GetMedia($link,$w,$h)
87 {
88 if (!isset($link)) return;
89
90 if ($w) $w="width=".$w;
91 if ($h) $h="height=".$h;
92
93 $ext=GetFileExtention($link);
94 switch ($ext)
95 {
96 case ".swf":
97 ?>
98 <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj5" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" <? echo $w; ?> <? echo $h; ?>>
99 <param name="movie" value="<? echo $link; ?>">
100 <param name="quality" value="High">
101 <embed src="'.$link.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj5" <? echo $w; ?> <? echo $h; ?> quality="High"></object>
102 <?
103 break;
104 case ".gif":
105 case ".jpg":
106 case ".bmp":
107 case ".png":
108 ?>
109 <img <? echo $w; ?> <? echo $h; ?> border="0" src="<? echo $link; ?>">
110 <?
111 break;
112 default:
113 break;
114 }
115 }
116
117 function GetMediao($link)
118
119 {
120
121 $ret="";
122
123 $ext=GetFileExtention($link);
124
125 switch ($ext)
126
127 {
128
129 case ".swf":
130
131 $ret='<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj5" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="468" height="90">';
132
133 $ret.='<param name="movie" value="'.$link.'">';
134
135 $ret.='<param name="quality" value="High">';
136
137 $ret.='<embed src="'.$link.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj5" width="468" height="90" quality="High"></object>';
138
139 break;
140
141 case ".gif":
142
143 case ".jpg":
144
145 case ".bmp":
146
147 case ".png":
148
149 $ret='<img border="0" src="'.$link.'">';
150
151 break;
152
153 default:
154
155 break;
156
157 }
158
159 return $ret;
160
161 }
162
163 function GetMedia1($link)
164
165 {
166
167 $ret="";
168
169 $ext=GetFileExtention($link);
170
171 switch ($ext)
172
173 {
174
175 case ".swf":
176
177 $ret='<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj5" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="440" height="80">';
178
179 $ret.='<param name="movie" value="'.$link.'">';
180
181 $ret.='<param name="quality" value="High">';
182
183 $ret.='<embed src="'.$link.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj5" width="440" height="80" quality="High"></object>';
184
185 break;
186
187 case ".gif":
188
189 case ".jpg":
190
191 case ".bmp":
192
193 case ".png":
194
195 $ret='<img border="0" src="'.$link.'">';
196
197 break;
198
199 default:
200
201 break;
202
203 }
204
205 return $ret;
206
207 }
208
209
210
211 function checkemail($email)
212
213 {
214
215 if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
216
217 return false;
218
219 return true;
220
221 }
222
223
224
225 function sendmail1($from,$to,$subject,$body)
226
227 {
228
229 /*
230
231 return mail_smtp($from,$to,$subject,$body,1);
232
233 */
234
235 $mailheaders = "MIME-Version: 1.0\r\n";
236
237 $mailheaders .= "Content-type: text/html; charset=windows-1252\r\n";
238
239 $mailheaders .= "From: <".$from."> \n";
240
241 $mailheaders .= "Reply-To: ".$from;
242
243 return mail($to, $subject, $body, $mailheaders,"-fwebmaster@{$_SERVER['SERVER_NAME']}");
244
245 }
246
247 function sendmail($from,$to,$subject,$body)
248
249 {
250 return mail_smtp($from,$to,$subject,$body,1);
251 }
252
253
254 function mail_smtp($from,$to,$subject,$body,$html=0)
255
256 {
257
258 require_once("smtp.php");
259
260
261
262 /* Uncomment when using SASL authentication mechanisms */
263
264 /*
265
266 require("sasl.php");
267
268 */
269
270
271
272 //$from=""; /* Change this to your address like "me@mydomain.com"; */
273
274 //$to=""; /* Change this to your test recipient address */
275
276
277
278 $smtp=new smtp_class;
279
280
281
282 $smtp->host_name="localhost"; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
283
284 $smtp->localhost="localhost"; /* Your computer address */
285
286 $smtp->direct_delivery=0; /* Set to 1 to deliver directly to the recepient SMTP server */
287
288 $smtp->timeout=10; /* Set to the number of seconds wait for a successful connection to the SMTP server */
289
290 $smtp->data_timeout=0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server.
291
292 Set to 0 to use the same defined in the timeout variable */
293
294 $smtp->debug=0; /* Set to 1 to output the communication with the SMTP server */
295
296 $smtp->html_debug=1; /* Set to 1 to format the debug output as HTML */
297
298 $smtp->pop3_auth_host=""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */
299
300 $smtp->user=""; /* Set to the user name if the server requires authetication */
301
302 $smtp->realm=""; /* Set to the authetication realm, usually the authentication user e-mail domain */
303
304 $smtp->password=""; /* Set to the authetication password */
305
306 $smtp->workstation=""; /* Workstation name for NTLM authentication */
307
308 $smtp->authentication_mechanism=""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc..
309
310 Leave it empty to make the class negotiate if necessary */
311
312
313
314 /*
315
316 * If you need to use the direct delivery mode and this is running under
317
318 * Windows or any other platform that does not have enabled the MX
319
320 * resolution function GetMXRR() , you need to include code that emulates
321
322 * that function so the class knows which SMTP server it should connect
323
324 * to deliver the message directly to the recipient SMTP server.
325
326 */
327
328 if($smtp->direct_delivery)
329
330 {
331
332 if(!function_exists("GetMXRR"))
333
334 {
335
336 /*
337
338 * If possible specify in this array the address of at least on local
339
340 * DNS that may be queried from your network.
341
342 */
343
344 $_NAMESERVERS=array();
345
346 include("getmxrr.php");
347
348 }
349
350 /*
351
352 * If GetMXRR function is available but it is not functional, to use
353
354 * the direct delivery mode, you may use a replacement function.
355
356 */
357
358 /*
359
360 else
361
362 {
363
364 $_NAMESERVERS=array();
365
366 if(count($_NAMESERVERS)==0)
367
368 Unset($_NAMESERVERS);
369
370 include("rrcompat.php");
371
372 $smtp->getmxrr="_getmxrr";
373
374 }
375
376 */
377
378 }
379
380
381
382 $header="";
383
384 if ($html==0)
385
386 $header=array(
387
388 "From: $from",
389
390 "To: $to",
391
392 "Subject: $subject",
393
394 "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"));
395
396 else
397
398 $header=array(
399
400 "MIME-Version: 1.0",
401
402 "Content-type: text/html; charset=iso-8859-1",
403
404 "From: $from",
405
406 "To: $to",
407
408 "Subject: $subject",
409
410 "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"));
411
412 $ret=$smtp->SendMessage($from,array($to),$header,$body);
413
414 return $ret;
415
416 }
417
418
419
420 function insert($table,$fields_arr) {
421
422 global $con;
423
424 if (!$con) { return false; }
425
426 $strfields="";
427
428 $strvalues="";
429
430 list($key, $val) = each($fields_arr);
431
432 if(is_string($key))
433
434 {
435
436 $strfields = " ($key";
437
438 $strvalues= $val;
439
440 while(list($key, $val) = each($fields_arr))
441
442 {
443
444 $strfields.= ", $key";
445
446 $strvalues.= ",". $val;
447
448 }
449
450 $strfields.=")";
451
452 }
453
454 else
455
456 {
457
458 $strvalues=$fields_arr[0];
459
460 for($i=1;$i<(count($fields_arr));$i++)
461
462 {
463
464 $strvalues .= ", $fields_arr[$i]";
465
466 }
467
468 }
469
470
471
472 $query = "INSERT INTO $table $strfields VALUES ($strvalues)";
473
474 //echo $query;
475
476 return mysql_query($query, $con);
477
478 }
479
480
481
482 function update($table,$id,$valueid,$fields_arr,$where_ext="",$ischangepassword = 0) {
483
484 global $con;
485
486 if (!$con) { return false; }
487
488 list($key, $val) = each($fields_arr);
489
490 $strset=" $key = $val";
491
492 while(list($key, $val) = each($fields_arr)){
493
494 $strset .= ", $key = $val";
495
496 }
497
498
499
500 $query = "UPDATE $table SET
501
502 $strset
503
504 WHERE $id='$valueid' $where_ext";
505
506 #echo $query."<br>";
507
508 $result = mysql_db_query($query, $con);
509
510 if (!$result) { return false; }
511
512 else
513
514 if($ischangepassword ==1 && mysql_affected_rows() == 0) return false;
515
516 else return true;
517
518 }
519
520
521
522 function delete_rows($table,$fields_arr,$where_ext="") {
523
524 global $con;
525
526 if (!$con) { return false; }
527
528 if(count($fields_arr)>0){
529
530 list($key, $val) = each($fields_arr);
531
532 $strwhere=" $key = $val";
533
534 while(list($key, $val) = each($fields_arr)){
535
536 $strwhere .= "OR $key = $val";
537
538 }
539
540 }
541
542
543
544 $query = "DELETE FROM $table
545
546 WHERE $strwhere $where_ext";
547
548 #echo $query;#exit;
549
550 $result = mysql_query($query, $con);
551
552 if (!$result) {
553
554 return false;
555
556 }
557
558 return true;
559
560 }
561
562
563
564 function count_record($table,$where_ext = ""){
565
566 global $con;
567
568 if (!$con) { return false; }
569
570 $query = "SELECT count(*) FROM $table ";
571
572 if($where_ext != "")
573
574 $query.= " WHERE " . $where_ext;
575
576 //echo $query,"<br>";
577
578 $result = mysql_query($query, $con);
579
580 if ($result) {
581
582 $rows = mysql_fetch_row($result);
583
584 return $rows[0];
585
586 } else {
587
588 return false;
589
590 }
591
592
593
594 }
595
596
597
598 function query_get($query) {
599
600 global $con;
601
602 if (!$con) { return false; }
603
604 $result = mysql_query($query, $con);
605
606 if ($result) {
607
608 while ($rows = mysql_fetch_array($result)) {
609
610 $return[] = $rows;
611
612 }
613
614 return $return;
615
616 } else {
617
618 return false;
619
620 }
621
622 }
623
624
625
626 function query_get_list($query, $begin, $limit,$where_ext="",$orderby="") {
627
628 global $con;
629
630 if (!$con) { return false; }
631
632 $return=array();
633
634 $query1 = $query;
635
636 if($where_ext<>"")
637
638 $query1 .= " WHERE " .$where_ext;
639
640
641
642 $query1.= $orderby;
643
644
645
646 if($begin >=0 && $limit > 0)
647
648 $query1 .=" LIMIT $begin, $limit ";
649
650 echo $quety1;
651
652 $result = mysql_query($query1, $con);
653
654 if ($result) {
655
656 while ($rows = mysql_fetch_array($result)) {
657
658 $return[] = $rows;
659
660 }
661
662
663
664 return $return;
665
666 } else {
667
668 return false;
669
670 }
671
672 }
673
674 ?>
2
3 function chuanhoa($s)
4
5 {
6
7 //return trim(htmlspecialchars($s));
8
9 return str_replace("<","<",trim($s));
10
11 }
12
13
14
15 function breakline($s)
16
17 {
18
19 return str_replace("\n","<br>",$s);
20
21 }
22
23
24
25 function GetFileExtention($filename)
26
27 {
28
29 return strrchr($filename, ".");
30
31 }
32
33
34
35 function CheckUpload($f,$ext="",$maxsize=0,$req=0)
36
37 {
38
39 $fname=strtolower(basename($f['name']));
40
41 $ftemp=$f["tmp_name"];
42
43 $fsize=$f["size"];
44
45 $fext=GetFileExtention($fname);
46
47 if($fsize==0)
48
49 {
50
51 if ($req!=0) return "Bạn chưa chọn file";
52
53 return "";
54
55 }
56
57 else
58
59 {
60
61 if ($ext!="") if (strpos($ext, $fext)===false) return "Tập tin không đúng định dạng : $fname";
62
63 //if(($f["type"] != "image/gif" ) && ($f["type"] != "image/pjpeg")) return "Định dạng file không hợp lệ";
64
65 if ($maxsize>0) if ($fsize > $maxsize) return "Kích thước hình phải nhỏ hơn ".$maxsize." byte";
66
67 }
68
69 return "";
70
71 }
72
73
74
75 function MakeUpload($f,$newfile)
76
77 {
78 //if (file_exists($newfile)) return false;
79
80 if (move_uploaded_file($f["tmp_name"], $newfile)) return $newfile;
81
82 return false;
83
84 }
85
86 function GetMedia($link,$w,$h)
87 {
88 if (!isset($link)) return;
89
90 if ($w) $w="width=".$w;
91 if ($h) $h="height=".$h;
92
93 $ext=GetFileExtention($link);
94 switch ($ext)
95 {
96 case ".swf":
97 ?>
98 <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj5" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" <? echo $w; ?> <? echo $h; ?>>
99 <param name="movie" value="<? echo $link; ?>">
100 <param name="quality" value="High">
101 <embed src="'.$link.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj5" <? echo $w; ?> <? echo $h; ?> quality="High"></object>
102 <?
103 break;
104 case ".gif":
105 case ".jpg":
106 case ".bmp":
107 case ".png":
108 ?>
109 <img <? echo $w; ?> <? echo $h; ?> border="0" src="<? echo $link; ?>">
110 <?
111 break;
112 default:
113 break;
114 }
115 }
116
117 function GetMediao($link)
118
119 {
120
121 $ret="";
122
123 $ext=GetFileExtention($link);
124
125 switch ($ext)
126
127 {
128
129 case ".swf":
130
131 $ret='<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj5" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="468" height="90">';
132
133 $ret.='<param name="movie" value="'.$link.'">';
134
135 $ret.='<param name="quality" value="High">';
136
137 $ret.='<embed src="'.$link.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj5" width="468" height="90" quality="High"></object>';
138
139 break;
140
141 case ".gif":
142
143 case ".jpg":
144
145 case ".bmp":
146
147 case ".png":
148
149 $ret='<img border="0" src="'.$link.'">';
150
151 break;
152
153 default:
154
155 break;
156
157 }
158
159 return $ret;
160
161 }
162
163 function GetMedia1($link)
164
165 {
166
167 $ret="";
168
169 $ext=GetFileExtention($link);
170
171 switch ($ext)
172
173 {
174
175 case ".swf":
176
177 $ret='<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj5" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="440" height="80">';
178
179 $ret.='<param name="movie" value="'.$link.'">';
180
181 $ret.='<param name="quality" value="High">';
182
183 $ret.='<embed src="'.$link.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj5" width="440" height="80" quality="High"></object>';
184
185 break;
186
187 case ".gif":
188
189 case ".jpg":
190
191 case ".bmp":
192
193 case ".png":
194
195 $ret='<img border="0" src="'.$link.'">';
196
197 break;
198
199 default:
200
201 break;
202
203 }
204
205 return $ret;
206
207 }
208
209
210
211 function checkemail($email)
212
213 {
214
215 if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
216
217 return false;
218
219 return true;
220
221 }
222
223
224
225 function sendmail1($from,$to,$subject,$body)
226
227 {
228
229 /*
230
231 return mail_smtp($from,$to,$subject,$body,1);
232
233 */
234
235 $mailheaders = "MIME-Version: 1.0\r\n";
236
237 $mailheaders .= "Content-type: text/html; charset=windows-1252\r\n";
238
239 $mailheaders .= "From: <".$from."> \n";
240
241 $mailheaders .= "Reply-To: ".$from;
242
243 return mail($to, $subject, $body, $mailheaders,"-fwebmaster@{$_SERVER['SERVER_NAME']}");
244
245 }
246
247 function sendmail($from,$to,$subject,$body)
248
249 {
250 return mail_smtp($from,$to,$subject,$body,1);
251 }
252
253
254 function mail_smtp($from,$to,$subject,$body,$html=0)
255
256 {
257
258 require_once("smtp.php");
259
260
261
262 /* Uncomment when using SASL authentication mechanisms */
263
264 /*
265
266 require("sasl.php");
267
268 */
269
270
271
272 //$from=""; /* Change this to your address like "me@mydomain.com"; */
273
274 //$to=""; /* Change this to your test recipient address */
275
276
277
278 $smtp=new smtp_class;
279
280
281
282 $smtp->host_name="localhost"; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
283
284 $smtp->localhost="localhost"; /* Your computer address */
285
286 $smtp->direct_delivery=0; /* Set to 1 to deliver directly to the recepient SMTP server */
287
288 $smtp->timeout=10; /* Set to the number of seconds wait for a successful connection to the SMTP server */
289
290 $smtp->data_timeout=0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server.
291
292 Set to 0 to use the same defined in the timeout variable */
293
294 $smtp->debug=0; /* Set to 1 to output the communication with the SMTP server */
295
296 $smtp->html_debug=1; /* Set to 1 to format the debug output as HTML */
297
298 $smtp->pop3_auth_host=""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */
299
300 $smtp->user=""; /* Set to the user name if the server requires authetication */
301
302 $smtp->realm=""; /* Set to the authetication realm, usually the authentication user e-mail domain */
303
304 $smtp->password=""; /* Set to the authetication password */
305
306 $smtp->workstation=""; /* Workstation name for NTLM authentication */
307
308 $smtp->authentication_mechanism=""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc..
309
310 Leave it empty to make the class negotiate if necessary */
311
312
313
314 /*
315
316 * If you need to use the direct delivery mode and this is running under
317
318 * Windows or any other platform that does not have enabled the MX
319
320 * resolution function GetMXRR() , you need to include code that emulates
321
322 * that function so the class knows which SMTP server it should connect
323
324 * to deliver the message directly to the recipient SMTP server.
325
326 */
327
328 if($smtp->direct_delivery)
329
330 {
331
332 if(!function_exists("GetMXRR"))
333
334 {
335
336 /*
337
338 * If possible specify in this array the address of at least on local
339
340 * DNS that may be queried from your network.
341
342 */
343
344 $_NAMESERVERS=array();
345
346 include("getmxrr.php");
347
348 }
349
350 /*
351
352 * If GetMXRR function is available but it is not functional, to use
353
354 * the direct delivery mode, you may use a replacement function.
355
356 */
357
358 /*
359
360 else
361
362 {
363
364 $_NAMESERVERS=array();
365
366 if(count($_NAMESERVERS)==0)
367
368 Unset($_NAMESERVERS);
369
370 include("rrcompat.php");
371
372 $smtp->getmxrr="_getmxrr";
373
374 }
375
376 */
377
378 }
379
380
381
382 $header="";
383
384 if ($html==0)
385
386 $header=array(
387
388 "From: $from",
389
390 "To: $to",
391
392 "Subject: $subject",
393
394 "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"));
395
396 else
397
398 $header=array(
399
400 "MIME-Version: 1.0",
401
402 "Content-type: text/html; charset=iso-8859-1",
403
404 "From: $from",
405
406 "To: $to",
407
408 "Subject: $subject",
409
410 "Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z"));
411
412 $ret=$smtp->SendMessage($from,array($to),$header,$body);
413
414 return $ret;
415
416 }
417
418
419
420 function insert($table,$fields_arr) {
421
422 global $con;
423
424 if (!$con) { return false; }
425
426 $strfields="";
427
428 $strvalues="";
429
430 list($key, $val) = each($fields_arr);
431
432 if(is_string($key))
433
434 {
435
436 $strfields = " ($key";
437
438 $strvalues= $val;
439
440 while(list($key, $val) = each($fields_arr))
441
442 {
443
444 $strfields.= ", $key";
445
446 $strvalues.= ",". $val;
447
448 }
449
450 $strfields.=")";
451
452 }
453
454 else
455
456 {
457
458 $strvalues=$fields_arr[0];
459
460 for($i=1;$i<(count($fields_arr));$i++)
461
462 {
463
464 $strvalues .= ", $fields_arr[$i]";
465
466 }
467
468 }
469
470
471
472 $query = "INSERT INTO $table $strfields VALUES ($strvalues)";
473
474 //echo $query;
475
476 return mysql_query($query, $con);
477
478 }
479
480
481
482 function update($table,$id,$valueid,$fields_arr,$where_ext="",$ischangepassword = 0) {
483
484 global $con;
485
486 if (!$con) { return false; }
487
488 list($key, $val) = each($fields_arr);
489
490 $strset=" $key = $val";
491
492 while(list($key, $val) = each($fields_arr)){
493
494 $strset .= ", $key = $val";
495
496 }
497
498
499
500 $query = "UPDATE $table SET
501
502 $strset
503
504 WHERE $id='$valueid' $where_ext";
505
506 #echo $query."<br>";
507
508 $result = mysql_db_query($query, $con);
509
510 if (!$result) { return false; }
511
512 else
513
514 if($ischangepassword ==1 && mysql_affected_rows() == 0) return false;
515
516 else return true;
517
518 }
519
520
521
522 function delete_rows($table,$fields_arr,$where_ext="") {
523
524 global $con;
525
526 if (!$con) { return false; }
527
528 if(count($fields_arr)>0){
529
530 list($key, $val) = each($fields_arr);
531
532 $strwhere=" $key = $val";
533
534 while(list($key, $val) = each($fields_arr)){
535
536 $strwhere .= "OR $key = $val";
537
538 }
539
540 }
541
542
543
544 $query = "DELETE FROM $table
545
546 WHERE $strwhere $where_ext";
547
548 #echo $query;#exit;
549
550 $result = mysql_query($query, $con);
551
552 if (!$result) {
553
554 return false;
555
556 }
557
558 return true;
559
560 }
561
562
563
564 function count_record($table,$where_ext = ""){
565
566 global $con;
567
568 if (!$con) { return false; }
569
570 $query = "SELECT count(*) FROM $table ";
571
572 if($where_ext != "")
573
574 $query.= " WHERE " . $where_ext;
575
576 //echo $query,"<br>";
577
578 $result = mysql_query($query, $con);
579
580 if ($result) {
581
582 $rows = mysql_fetch_row($result);
583
584 return $rows[0];
585
586 } else {
587
588 return false;
589
590 }
591
592
593
594 }
595
596
597
598 function query_get($query) {
599
600 global $con;
601
602 if (!$con) { return false; }
603
604 $result = mysql_query($query, $con);
605
606 if ($result) {
607
608 while ($rows = mysql_fetch_array($result)) {
609
610 $return[] = $rows;
611
612 }
613
614 return $return;
615
616 } else {
617
618 return false;
619
620 }
621
622 }
623
624
625
626 function query_get_list($query, $begin, $limit,$where_ext="",$orderby="") {
627
628 global $con;
629
630 if (!$con) { return false; }
631
632 $return=array();
633
634 $query1 = $query;
635
636 if($where_ext<>"")
637
638 $query1 .= " WHERE " .$where_ext;
639
640
641
642 $query1.= $orderby;
643
644
645
646 if($begin >=0 && $limit > 0)
647
648 $query1 .=" LIMIT $begin, $limit ";
649
650 echo $quety1;
651
652 $result = mysql_query($query1, $con);
653
654 if ($result) {
655
656 while ($rows = mysql_fetch_array($result)) {
657
658 $return[] = $rows;
659
660 }
661
662
663
664 return $return;
665
666 } else {
667
668 return false;
669
670 }
671
672 }
673
674 ?>